import React from 'react'

import { useSelector, useDispatch } from 'react-redux'
  import * as counterModules from '../store/modules/counter';
  
export default function Counter() {

    const count=useSelector((state)=>{
        // console.log('state',state)
        return state.counter.count
    })
    const dispatch=useDispatch()
    function add(){
      console.log('counterModules9999',counterModules)
      dispatch(counterModules.addcount(2))
    }

      function asyncAdd(){
        console.log('counterModules',counterModules);
        
          dispatch(counterModules.asyncAdd(3))

      }
  return (
    <div>Counter {count}  <button onClick={add}>add</button> <button onClick={asyncAdd}>异步按钮</button></div>
  )
}
